package com.zsc.oj.model.enums;

public enum TeamStatusEnums {
    PUBLIC(0, "公开"),
    PRIVATE(1, "私有"),
    SECRET(2, "加密");

    private int num;

    private String text;

    /**
     * 根据队伍status属性的数值获取对应的状态码
     *
     * @param num
     * @return
     */
    public static TeamStatusEnums getEnumByNum(Integer num) {
        if (num == null) {
            return null;
        }
        //这是枚举类的一个方法【枚举类.values()】，将所有的枚举情况转换成一个数组
        TeamStatusEnums[] values = TeamStatusEnums.values();
        for (TeamStatusEnums teamStatusEnums : values) {
            if (teamStatusEnums.getNum() == num) {
                return teamStatusEnums;
            }
        }
        return null;
    }

    TeamStatusEnums(int num, String text) {
        this.num = num;
        this.text = text;
    }

    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }
}
